package net.wsfcp.android.http.mvp.presenter;

import net.wsfcp.android.base.BasePresenter;
import net.wsfcp.android.bean.resultbean.OrderBean;
import net.wsfcp.android.http.mvp.contract.OrderListContract;
import net.wsfcp.android.http.mvp.model.OrderListModel;
import net.wsfcp.android.http.mvp.IModel;
import net.wsfcp.android.ui.view.my.fragment.OrderFragment;

import java.util.HashMap;

/**
 * Created by Shaoboyang on 2018/12/14.
 */
//订单列表
public class OrderListPresenter extends BasePresenter<OrderFragment> implements
        OrderListContract.OrderListPresenter {


    @Override
    public void getOrderList(int page, int pagesize, int status) {
        ((OrderListModel) getiModelMap().get("orderlist")).getOrderList(page, pagesize, status, new OrderListModel
                .OrderListInfoHint() {
            @Override
            public void getOrderListSuccessInfo(OrderBean orderBean) {
                getIView().getOrderListSuccess(orderBean);
            }

            @Override
            public void getOrderListFailInfo(String str) {
                getIView().getOrderListFail(str);
            }


        });
    }

    @Override
    public void cancelOrder(String id) {
        ((OrderListModel) getiModelMap().get("cancel")).cancelOrder(id, new OrderListModel
                .CancelOrderInfoHint() {
            @Override
            public void cancelOrderSuccessInfo() {
                getIView().cancelOrderSuccess();
            }

            @Override
            public void cancelOrderFailInfo(String str) {
                getIView().cancelOrderFail(str);
            }


        });
    }

    @Override
    public void confirmReceipt(String id) {
        ((OrderListModel) getiModelMap().get("confirm")).confirmReceipt(id, new OrderListModel
                .ConfirmReceiptInfoHint() {
            @Override
            public void confirmReceiptSuccessInfo() {
                getIView().confirmReceiptSuccess();
            }

            @Override
            public void confirmReceiptFailInfo(String str) {
                getIView().confirmReceiptFail(str);
            }



        });

    }

    @Override
    public void getOrderDetail(String id) {

    }


    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new OrderListModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> map = new HashMap<>();
        map.put("orderlist", models[0]);
        map.put("cancel", models[0]);
        map.put("confirm", models[0]);
        return map;
    }


}
